package cn.szzsi._admin;

import cn.szzsi.service.BusinessDataStatisticsService;
import cn.szzsi.common.bean.dto.Msg;
import cn.szzsi.common.model.Member;
import com.jfinal.aop.Clear;

import java.util.HashMap;
import java.util.Map;

/**
 * 数据统计
 * Created by yuanzheng on 2016/12/20.
 */
public class DataStatisticsController extends BaseAdminController<Member> {
    private String shopId;
    //收入,订单,访客
    @Clear
    public void base(){
        shopId=getAttr("shopId");
        Map<String ,Object> map=new HashMap<String ,Object>();
        map= BusinessDataStatisticsService.bdss.getBaseData(shopId);
        renderJson(map);
    }

    //会员数,商品数
    public void mpnums(){
        shopId=getAttr("shopId");
        Map<String,Object> map=BusinessDataStatisticsService.bdss.getMemberAndProduct(shopId);
        renderJson(map);
    }

    //用户反馈
    public void feedback(){
        shopId=getAttr("shopId");
        Map<String ,Object> map=BusinessDataStatisticsService.bdss.getFeedBack(shopId);
        renderJson(Msg.success(map));
    }

    //获取最新注册用户
    public void newuser(){
        shopId=getAttr("shopId");
        Map<String ,Object> map=BusinessDataStatisticsService.bdss.getNewUser(shopId);
        renderJson(Msg.success(map));
    }

    //库存预警
    public void storeWarning(){
        shopId=getAttr("shopId");
        Map<String ,Object> map=BusinessDataStatisticsService.bdss.getStoreWarning(shopId);
        //System.out.println(JsonKit.toJson(Msg.success(map)));
        renderJson(Msg.success(map));
    }
}
